<%--
  Created by IntelliJ IDEA.
  User: 朱泽丹
  Date: 2021-12-09
  Time: 10:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>ajax实现密码提示信息</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
    <script>
        function a1(){
            // $.post();
            $.post({
                url:"${pageContext.request.contextPath}/a3.action",
                data:{"name":$("#name").val()},
                success:function (data){
                    if(data.toString() == "ok"){
                        $("#userInfo").css("color","green");
                    }else {
                        $("#userInfo").css("color","red");
                    }
                    $("#userInfo").html(data);
                }
            });
        }
        function a2(){
            // $.post();
            $.post({
                url:"${pageContext.request.contextPath}/a3.action",
                data:{"pwd":$("#pwd").val()},
                success:function (data){
                    if(data.toString() == "ok"){
                        $("#pwdInfo").css("color","green");
                    }else {
                        $("#pwdInfo").css("color","red");
                    }
                    $("#pwdInfo").html(data);
                }
            });
        }
    </script>
</head>
<body>
    <p>
        用户名：<input type="text" id="name" onblur="a1()">
        <span id="userInfo"></span>
    </p>
    <p>
        密&nbsp;&nbsp;&nbsp;&nbsp;码：<input type="text" id="pwd" onblur="a2()">
        <span id="pwdInfo"></span>
    </p>
</body>
</html>
